const root = {
    val: 14,
    left: {
        val: 7,
        left: {
            val: 3,
        },
        right: {
            val: 9,
        },
    },
    right: {
        val: 18,
        left: {
            val: 16,
        },
        right: {
            val: 19,
        },
    },
};

// 时间复杂度为O(logn)
function searchBST(root, val) {
    if (!root) {
        return null
    }
    if (val === root.val) {
        return root
    } else if (val < root.val) {
        return searchBST(root.left, val)
    } else {
        return searchBST(root.right, val)
    }
}

console.log(searchBST(root, 0));